#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>


int main(int argc, const char *argv[])
{
	mkfifo("./pipe1",0666);
	mkfifo("./pipe2",0666);
	int fd1=open("./pipe1",O_RDWR);
	int fd2=open("./pipe2",O_RDWR);

	pid_t pid=fork();
	if(pid==0)
	{
		char writebuf[32]={0};
		while(1)
		{
			scanf("%s",writebuf);
			write(fd1,writebuf,32);
			memset(writebuf,0,32);
		}

	}
	else if(pid>0)
	{
		char readbuf[32]={0};
		while(1)
		{
			if(read(fd2,readbuf,32)>0)
			{
				printf("recv2: %s\n",readbuf);
				memset(readbuf,0,32);
			}

		}
	}



	return 0;
}
